package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdDiscussMapper;
import com.diankangwo.factory.entity.TdDiscuss;
import com.diankangwo.factory.service.TdDiscussServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("TdDiscussServices")
public class TdDiscussServicesImpl implements TdDiscussServices {

    @Autowired
    private TdDiscussMapper  mapper;

    /**
     * 根据条件获取评论列表
     * @param map
     * @return
     */
    @Override
    public List<TdDiscuss> queryList(Map<String, Object> map) {
        return mapper.queryList(map);
    }

    /**
     * 根据条件获取总数
     * @param map
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return mapper.queryTotal(map);
    }

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Override
    public TdDiscuss querybyId(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    /**
     * 根据用户id查询
     * @param userid
     * @return
     */
    @Override
    public List<TdDiscuss> queryByUserId(int userid) {
        return mapper.queryByUserId(userid);
    }

    /**
     * 根据商品ID查询
     * @param commodityid
     * @return
     */
    @Override
    public List<TdDiscuss> queryByCommodityid(int commodityid) {
        return mapper.queryBycommodityId(commodityid);
    }

    /**
     * 修改
     * @param tdDiscuss
     */
    @Override
    @Transactional
    public void update(TdDiscuss tdDiscuss) {
        mapper.updateByPrimaryKey(tdDiscuss);
    }

    /**
     * 删除
     * @param discussIds
     */
    @Override
    @Transactional
    public void deleteBatch(int[] discussIds) {
        mapper.deleteBatch(discussIds);
    }

    @Override
    public List<TdDiscuss> queryByDay(String startTime, String endTime) {
        return mapper.queryByDay(startTime,endTime);
    }
}
